import { GetterTree } from 'vuex'
import { construct } from "@aximario/json-tree";
import { eachTree, queryTree } from "@/utils"
import userCookies from "@/utils/data/cookies";
export const getters: GetterTree<any, any> = {
    bigTree(state, { tree }) {
        eachTree(tree)
        const data = queryTree(tree, function (item: any) {
            return item.level <= 1;
        }, {
            id: 'section_sn',
            pid: 'section_psn'
        });
        return [{ section_sn: userCookies.get('yard_sn'), section_name: userCookies.get('yard_name'), children: data }]
    },
    tree({ tree }) {
        return construct(tree, {
            id: 'section_sn',
            pid: 'section_psn'
        });
    },
    staff({ staff }) {
        return construct(staff, {
            id: 'section_sn',
            pid: 'section_psn'
        });
    }
}